<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{$is_language?'積分變動記錄':'Record changes in balance'}</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/weui.min.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/jquery-weui.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/demos.css">
    <script src="__MODULE_LIBS__/js/jquery-2.1.4.js"></script>
    <script src="__MODULE_LIBS__/js/fastclick.js"></script>
    <script src="__MODULE_LIBS__/js/jquery-weui.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            font-size: 14px;
        }

        html {
            width: 100%;
            height: 100%;
            font-size: 20px;
            font-family: "Microsoft YaHei", "宋体", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
            background: #F3F3F3;
        }

        body {
            margin: 0 auto;
            max-width: 750px;
            height: 100%;
            background: #F7F7F7;
        }

        /*顶部导航栏处的样式*/
        .navbar {
            position: relative;
            width: 100%;
            height: 2rem;
            font-size: 16px;
            color: #fff;
            line-height: 2rem;
            background: #373553;
        }

        .navbar-item {
            position: absolute;
            left: 0;
            top: 0;
            display: block;
            width: 3.2rem;
            height: 2rem;
            font-size: 14px;
            color: #fff;
            text-align: center;
        }

        .navbar-item > img {
            width: 0.8rem;
            height: 0.7rem;
            vertical-align: middle;
        }

        .navbar-center {
            text-align: center;
        }

        /*主体部分的样式*/
        .content {
            width: 100%;
        }
        .weui-loadmore {
            display: none;
        }
        .mes {
            text-align: center;
        }
        .weui-loadmore {
            display: none;
        }
    </style>
</head>
<body>
<header class="navbar">
    {if isset($user)}
    <a href="{:url('myteam/index')}" class="navbar-item">
        {else}
        <a href="{:url('index/index')}" class="navbar-item">
            {/if}
            <img src="__MODULE_LIBS__/img/back.png"/>&nbsp;{$is_language?'返回':'Return'}
        </a>
        <div class="navbar-center">{$is_language?'積分變動記錄':'Record changes in balance'}</div>
        <div class="navbar-item1">
            <select name="" id="yy">
                <option value="1" {$is_language?'selected':''}>中文</option>
                <option value="0" {$is_language?'':'selected'}>English</option>
            </select>
        </div>
</header>
<div class="content" id="rewardlist">
    <!--<div class="weui-cells">-->
        <!--<div class="weui-cell">-->
            <!--<div class="weui-cell__hd">-->
                <!--<p class="time">本金：100</p>-->
            <!--</div>-->
            <!--<div class="weui-cell__bd">-->
                <!--<p class="mes">2017.11.16</p>-->
            <!--</div>-->
            <!--<div class="weui-cell__ft">-->
                <!--<p class="status grey">转入：10</p>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="weui-cell">-->
            <!--备注：啊啊啊啊啊啊-->
        <!--</div>-->
    <!--</div>-->
</div>
<div class="weui-loadmore">
    <i class="weui-loading"></i>
</div>
<script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.min.js"></script>
<script type="text/javascript">
    var page=1;
    var loading = false;
    var url = "{:url('ajax')}";
    function show(){
        $(".weui-loadmore").show();
        $.ajax({
            type: "POST",
            url: url,
            dataType:"json",
            data:{page: page},
            success: function(data){
                console.log(data)
                var data = data.data;
                var html = '';
                for(var i=0; i<data.length; i++) {
                    html += `<div class="weui-cells">
                                <div class="weui-cell">
                                    <div class="weui-cell__hd">
                                        <p class="time">{$is_language?'當前金額':'principal'}：$${data[i].money}</p>
                                    </div>
                                    <div class="weui-cell__bd">
                                        <p class="mes">${data[i].type==0?"{$is_language?'減少':'Turn out'}":"{$is_language?'增加':'Turn into'}"}：$${data[i].money_change}</p>
                                    </div>
                                    <div class="weui-cell__ft">
                                        <p class="status grey">${data[i].time}</p>
                                    </div>
                                </div>
                                <div class="weui-cell" style="font-size: 12px;color: #9B9B9B">
                                    {$is_language?'備註':'Remarks'}：${data[i].content}
                                </div>
                            </div>`;
                }
                $('#rewardlist').append(html);
                p ++;
                $(".weui-loadmore").hide();
            }
        });
    }

    show();
    $(document.body).infinite().on("infinite", function() {
        if(loading) return;
        loading = true;
        setTimeout(function(){
            show();
            loading = false;
        },1000);
    });


    $(document).on("change",'select#yy',function(){
        var yy = $(this).val();
        console.log(yy)
        var url = "{:url('index/language')}";
        $.post(url,{language:yy},function (res) {
            window.location.reload();
        })
    });
    $(function () {
        FastClick.attach(document.body);
    })
</script>
</body>
</html>
